package com.tanhua.management.controller;

import cn.hutool.core.util.ObjectUtil;
import com.tanhua.management.service.MessageDetailService;
import com.tanhua.management.vo.MessageDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("manage")
public class MessageDetailController {

    @Autowired
    private MessageDetailService messageDetailService;

    /**
     *
     *  消息详情
     *
     * @param id    发布消息的人的动态Id
     * @return
     */
    @GetMapping("messages/{id}")
    public ResponseEntity<MessageDetailVo> queryMessageDetail(@PathVariable("id") String id) {
        try {
            MessageDetailVo messageDetailVo = messageDetailService.queryMessageDetail(id);
            if (ObjectUtil.isNotEmpty(messageDetailVo)) {
                return ResponseEntity.ok(messageDetailVo);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseEntity.status(500).build();

    }
}
